package com.wanshi.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.wanshi.utils.StringUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 
 * </p>
 *
 * @author 顽石教育-www.wanshi.com
 * @since 2021-12-08
 */
@Data
@EqualsAndHashCode(callSuper = false)

@TableName(autoResultMap = true)
@Accessors(chain = true)
public class User implements Serializable {

    private static final long serialVersionUID=1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    private String username;

    private String password;

    private String gender;

    @TableField(typeHandler = JacksonTypeHandler.class)
    private String[] hobby;

    private String city;

    private String picurl;

    private String introduce;

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", gender='" + gender + '\'' +
                ", hobby='" + hobby + '\'' +
                ", city='" + city + '\'' +
                ", introduce='" + introduce + '\'' +
                ", picurl='" + picurl + '\'' +
                '}';
    }

    //Map<String,String>  键是 input的name属性值, 值错误提示
  /*  public Map<String,String> checkUser(){
        Map<String,String> errorMap = new HashMap<>();
        String zhengze = "^[a-zA-Z0-9_]{6,20}$";
        if (StringUtils.isEmpty(username)){
            errorMap.put("username","用户名不能为空");
        }else if(!username.matches(zhengze)){
            errorMap.put("username","用户名不满足格式");
        }


        if(StringUtils.isEmpty(password)){
            errorMap.put("password","密码不能为空");
        }
        if(StringUtils.isEmpty(gender)){
            errorMap.put("gender","性别不能为空");
        }
        if(StringUtils.isEmpty(hobby)){
            errorMap.put("hobby","爱好不能为空");
        }
        if(StringUtils.isEmpty(city)){
            errorMap.put("city","城市不能为空");
        }
        if(StringUtils.isEmpty(introduce)){
            errorMap.put("introduce","自我介绍不能为空");
        }

        if(StringUtils.isEmpty(picurl)){
            errorMap.put("picurl","必须上传靓照");
        }

        return errorMap;

    }*/

}
